<?php
App::uses('ExceptionRenderer', 'Error');
// App::uses('AppController', 'Controller');
// App::uses('CakeEmail', 'Network/Email');
class AppExceptionRenderer extends ExceptionRenderer {
	public function __construct(Exception $exception) {
		parent::__construct($exception);
	}
	/*-------------------------------------------------------------------------*/
	/* -- Exceptions
	 /*-------------------------------------------------------------------------*/

	public function notFound($error) {
		//$this->controller->redirect(array('controller' => 'errors', 'action' => 'error404'));
		$this->controller->beforeFilter();
		$this->controller->set('title_for_layout', 'Error 404. Page not found!');
		$this->controller->render('/Errors/error404');
		$this->controller->response->send();
	}

	public function badRequest($error) {
		$this->controller->beforeFilter();
		$this->controller->set('title_for_layout', 'Bad request');
		$this->controller->render('/Errors/error400');
		$this->controller->response->send();
	}

	public function forbidden($error) {
		$this->controller->beforeFilter();
		$this->controller->set('title_for_layout', 'Forbidden');
		$this->controller->render('/Errors/error403');
		$this->controller->response->send();
	}

	public function methodNotAllowed($error) {
		$this->controller->beforeFilter();
		$this->controller->set('title_for_layout', 'NotAllowed');
		$this->controller->render('/Errors/error405');
		$this->controller->response->send();
	}

	public function internalError($error) {
		$this->controller->beforeFilter();
		$this->controller->set('title_for_layout', 'Internal Error');
		$this->controller->render('/Errors/error500');
		$this->controller->response->send();
	}

	public function notImplemented($error) {
		$this->controller->beforeFilter();
		$this->controller->set('title_for_layout', 'Not Implemented');
		$this->controller->render('/Errors/error501');
		$this->controller->response->send();
	}

	/*-------------------------------------------------------------------------*/
	/* -- Other
	 /*-------------------------------------------------------------------------*/

	public function missingController($error) {
		$this->notFound($error);
	}

	public function missingAction($error) {
		$this->notFound($error);
	}

	public function missingView($error) {
		$this->notFound($error);
	}

	public function missingLayout($error) {
		$this->internalError($error);
	}

	public function missingHelper($error) {
		$this->internalError($error);
	}

	public function missingBehavior($error) {
		$this->internalError($error);
	}
	public function missingComponent($error) {
		$this->internalError($error);
	}

	public function missingTask($error) {
		$this->internalError($error);
	}

	public function missingShell($error) {
		$this->internalError($error);
	}
	public function missingShellMethod($error) {
		$this->internalError($error);
	}

	public function missingDatabase($error) {
		$this->internalError($error);
	}

	public function missingConnection($error) {
		$this->internalError($error);
	}
	public function missingTable($error) {
		$this->internalError($error);
	}

	public function privateAction($error) {
		$this->internalError($error);
	}
}